﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

#if !WINRT
using System.Windows;
using System.Windows.Data;
#else
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
#endif

namespace MishraReader.Converters
{
    public class ActualWidthToNegativeMarginConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter,
#if !WINRT
            CultureInfo culture
#else
 string language
#endif
)
        {
            if (value == null)
                return new Thickness(0);

            var dvalue = System.Convert.ToDouble(value);

            if (double.IsNaN(dvalue))
                return new Thickness(0);

            return new Thickness(0, 0, -dvalue, 0);
        }

        public object ConvertBack(object value, Type targetType, object parameter,
#if !WINRT
            CultureInfo culture
#else
 string language
#endif
)
        {
            throw new NotImplementedException();
        }
    }
}